let t = 1234567.89
function foo(t) {
  let str = t.toString()
  let i = str.indexOf('.')
  let left = str.slice(0, i)
  let right = str.slice(i)
  let result = left[0] + ','
  let index = 1
  for (let j = 1; j < left.length; j++) {
    if (index % 3 == 0 && index != left.length - 1) {
      result = result + left[j] + ','
    } else {
      result = result + left[j]
    }
    index++
  }
  return result + right
}
console.log(foo(t))
console.log('test')